package com.liqw.spi.config;

import com.liqw.Constant;
import lombok.extern.slf4j.Slf4j;
import org.springframework.boot.autoconfigure.AutoConfigurationMetadata;
import org.springframework.boot.autoconfigure.AutoConfigurationImportFilter;

@Slf4j
public class CustomAutoConfigurationFilter implements AutoConfigurationImportFilter {

    @Override
    public boolean[] match(String[] autoConfigurationClasses, AutoConfigurationMetadata autoConfigurationMetadata) {
        System.out.println(Constant.getStepStr("CustomAutoConfigurationFilter.match", Constant.MODE_SPI) + "CustomAutoConfigurationFilter - 过滤配置");
        boolean[] matches = new boolean[autoConfigurationClasses.length];
        for (int i = 0; i < autoConfigurationClasses.length;  i++) {
            // 自定义过滤逻辑：这里示例过滤掉类名包含"DataSource"的配置类
//            matches[i] = !autoConfigurationClasses[i].contains("DataSource");
            matches[i] = true;
        }
        return matches;
    }
}